home *** CD-ROM | disk | FTP | other *** search
- /****************************************************************************************/
- /* FileOpenProc */
- /****************************************************************************************/
-
- #include "MyHeaders.h"
-
- short FileOpenProc ()
- {
- short FORetCode = 0;
- SFTypeList workTypeList;
- Rect dlogRect;
- short rectHeight, rectWidth;
- short newH, newV;
- short itemHit; /* return from modal dialog */
-
-
- myDlogPtr = GetNewDialog (getDlgID, NIL, (WindowPtr) -1); /* get the dialog */
-
- dlogRect = (*myDlogPtr).portRect; /* position dlog on desktop */
- rectHeight = dlogRect.bottom - dlogRect.top;
- rectWidth = dlogRect.right - dlogRect.left;
- newH = (screenBits.bounds.right - rectWidth) * .50; /* centered horizonally */
- newH += 2; /* jive it in */
- if (newH < 10) /* (not less than 10) */
- newH = 10;
- newV = ((screenBits.bounds.bottom - 30 /* vertical position */
- - rectHeight)* (.33)) + 30; /* one-third down */
- if (newV < 30) /* (not less than 30) */
- newV = 30;
-
- if (appIndex <= appCount) /* if Finder has selection */
- {
- GetAppFiles (appIndex, &appTheFile); /* get the info from Finder */
- workReply.good = TRUE; /* transfer to work area */
- workReply.vRefNum = appTheFile.vRefNum; /* ditto */
- workReply.fType = appTheFile.fType; /* ditto */
- workReply.version = appTheFile.versNum; /* ditto */
- workReply.fName[0] = appTheFile.fName[0]; /* ditto */
- strncpy ((char *) &workReply.fName[1], /* ditto */
- (char *) &appTheFile.fName[1],
- appTheFile.fName[0]);
- }
- else /* otherwise */
- /* get info from SF dialog */
- {
- workTypeList[0] = (long) 'TEXT'; /* set up to four types */
- workTypeList[1] = (long) 'ttro'; /* set up to four types */
- SetPt (&workPoint, newH,newV); /* upper left corner */
- SFGetFile (workPoint, NIL, NIL, 2, workTypeList, NIL, &workReply);
- if (workReply.good == FALSE) /* if cancel */
- {
- FORetCode = 1; /* set bad ret code */
- goto ENDING; /* get out */
- }
- }
-
- workRC = FSOpen (workReply.fName, /* open the file */
- workReply.vRefNum, &workPathRefNum);
- if (workRC != noErr)
- {
- ParamText (workReply.fName,NIL,NIL,NIL); /* set text as file name */
- PlaceAlert (134); /* position the alert */
- StopAlert (134, NIL); /* show the alert */
- FORetCode = 1; /* set bad ret code */
- }
-
- ENDING:
- return FORetCode;
- }